// Element Plus组件加载优化
import ElementPlus from 'element-plus'
import { ElButton, ElTable, ElTableColumn, ElForm, ElFormItem, ElInput, ElMessage, 
  ElCard, ElIcon, ElTag, ElPagination, ElRadio, ElRadioGroup, ElSelect, ElOption, 
  ElInputNumber, ElTabs, ElTabPane, ElRow, ElCol, ElEmpty, ElDialog, ElSwitch, ElSlider } from 'element-plus'

export const setupElementPlus = (app) => {
  try {
    // 添加全局配置对象
    app.config.globalProperties.$ELEMENT = {
      size: 'default',
      zIndex: 2000
    }
    
    // 注册核心组件
    app.use(ElButton)
    app.use(ElTable)
    app.use(ElTableColumn)
    app.use(ElForm)
    app.use(ElFormItem)
    app.use(ElInput)
    app.use(ElCard)
    app.use(ElIcon)
    app.use(ElTag)
    app.use(ElPagination)
    app.use(ElRadio)
    app.use(ElRadioGroup)
    app.use(ElSelect)
    app.use(ElOption)
    app.use(ElInputNumber)
    app.use(ElTabs)
    app.use(ElTabPane)
    app.use(ElRow)
    app.use(ElCol)
    app.use(ElEmpty)
    app.use(ElDialog)
    app.use(ElSwitch)
    app.use(ElSlider)
    
    // 添加全局消息方法
    app.config.globalProperties.$message = ElMessage
    
    // 注册完整的Element Plus
    app.use(ElementPlus)
    console.log('成功注册Element Plus组件')
    
    return true
  } catch (e) {
    console.error('加载ElementPlus失败:', e)
    return false
  }
} 